//
//  VisitorTableController.swift
//  传智小微博
//
//  Created by lxgoodgo on 16/4/17.
//  Copyright © 2016年 liux.orz. All rights reserved.
//
import SnapKit
import UIKit

class VisitorTableController: UITableViewController {

    var loginTag: Bool = false
    var vistorV: VisitorView?
    
    override func loadView() {
        loginTag ? super.loadView() : setupVistorView()
        
    }
    
    override func viewDidLoad() {
        super.viewDidLoad()
        
        
        
    }
    
    func setupNav()
    {
        self.navigationItem.leftBarButtonItem = UIBarButtonItem(title: "注册", style: UIBarButtonItemStyle.Plain, target: self, action: "login")
        self.navigationItem.rightBarButtonItem = UIBarButtonItem(title: "登录", style: UIBarButtonItemStyle.Plain, target: self, action: "login")
        
    }
    //进入 登录/注册页面
    @objc private func login()
    {
        let OAuthTc = OAuthTableController()
        self.presentViewController(UINavigationController(rootViewController: OAuthTc), animated: true , completion: nil)
        
    }
    
    //
    private func setupVistorView()
    {
        setupNav()
        
        vistorV = VisitorView()
        weak var weakSelf = self
        //定义闭包
        vistorV?.vistorClosure = {() -> () in
            weakSelf?.login()
            
        }
        view = vistorV
        view.backgroundColor = RGB(red: 237, green: 237, blue: 237)

    }
    

}
